#ifndef __DATABASE_INSTANCE_MANAGER__
#define __DATABASE_INSTANCE_MANAGER__

#include "databasemngr.h"
#include <string>
#include "factory.h"

class DataBaseInstanceMngr
{
  public:
    DataBaseInstanceMngr();
    virtual ~DataBaseInstanceMngr();

    static DataBaseInstanceMngr* getDataBaseInstanceMngr() {
      if(!pDataBaseInstanceMngr) {
         if((pDataBaseInstanceMngr = new(DataBaseInstanceMngr)))
            return pDataBaseInstanceMngr;
         else
            return 0;
       }
       else  {
         return pDataBaseInstanceMngr;
       }
    }

    static void DeleteDataBaseInstanceMngr()
    {
      delete pDataBaseInstanceMngr;
      pDataBaseInstanceMngr = 0;
    }

    DatabaseManager *getDatabaseManager(std::string db_name);
    DatabaseManager *setDatabaseManager(std::string db_name, class_buffer_base *pmngr);
    void deleteDatabaseManager(std::string db_name);

  protected:
    static DataBaseInstanceMngr* pDataBaseInstanceMngr;
    CFactory<DatabaseManager> db_mngr_factory;
};



#endif //__DATABASE_INSTANCE_MANAGER__
